 //获取元素
 let uu = document.querySelector("main#info>ul")
 let nav_three = document.querySelector("nav>a:nth-child(3)")
 let brandid = getQueryString("brandid")



 //首次渲染
 request(brandid)


 productDetails()


 /* 封装获取数据渲染 */
 function request(brandid) {
     fetch("http://chst.vip:1234/api/getbrandproductlist?brandtitleid=" + brandid + "&pagesize=10")
         .then(response => response.json())
         .then(res => {
             console.log(res.result);
             let domStr = ''
             res.result.forEach(item => {
                 // console.log(item);
                 domStr += `
             <li productId=${item.productId}>
                 <a href="#">
                     <div class="img">
                         ${item.productImg}
                     </div>
                     <div class="infoR">
                         <div class="title">
                             <h4>${item.productName}</h4>
                             <div class="price">${item.productPrice}</div>
                         </div>
                         <div class="other">
                             <span class="take_price">${item.productQuote}</span>
                             <i>${item.productCom}</i>
                         </div>
                     </div>
                 </a>
             </li>`
             })
             uu.innerHTML = domStr

         })
 }


 /* 点击进入商品详情页 */
 function productDetails() {
     // 点击获取商品的productid
     let productid;

     uu.addEventListener("click", function (e) {
         console.log(1);
         let _this = e.target;
         if (_this.className === "infoR") {
             productid = _this.parentNode.parentNode.getAttribute("productid")
             console.log(productid);
             location.href = "./ppdqlists.html?productid=" + productid
         } else if (_this.localName === "img") {
             productid = _this.parentNode.parentNode.parentNode.getAttribute("productid")
             console.log(productid);
             location.href = "./ppdqlists.html?productid=" + productid
         } else if (_this.localName === "h4" || _this.className === "price") {
             productid = _this.parentNode.parentNode.parentNode.parentNode.getAttribute("productid")
             console.log(productid);
             location.href = "./ppdqlists.html?productid=" + productid
         } else if (_this.localName === "i" || _this.localName === "span") {
             productid = _this.parentNode.parentNode.parentNode.parentNode.getAttribute("productid")
             console.log(productid);
             location.href = "./ppdqlists.html?productid=" + productid
         }
     }, true)
 }